import os
import string
dirName = "sandbox/image/"       #最后要加双斜杠，不然会报错
list=os.listdir(dirName)
idx = 0
class_name = "cone"
for filename in list:
    newname = filename
    newname = newname.split(".")
    newname[0] = "%s_%d" % (class_name, idx)
    idx = idx + 1
    newname = str.join(".",newname)  #这里要用str.join
    filename = dirName+filename
    newname = dirName+newname
    os.rename(filename,newname)
    print(newname,"updated successfully")